<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>登录-见微</title>
    <link href="__PUBLIC__/css/login.css" rel="stylesheet">
    <script type="text/javascript" src="//cdn.bootcss.com/jquery/1.12.1/jquery.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/Validform_v5.3.2_min.js"></script>
    <link href="__PUBLIC__/css/validform.css" rel="stylesheet">
</head>
<body>
<div class="main" style="background-image: url(__PUBLIC__/img/bg/<?php echo rand(0,4); ?>.jpg)">
    <div class="logo">
        <img src="__PUBLIC__/img/jianwei.png" alt="见微-全媒体记者发稿助手">
    </div>
    <div class="content">
        <form action="" class="login" method="post" id="loginForm">
            <div class="group">
                <div class="item">
                    <span class="label">账号:</span>
                    <input type="text" name="account" placeholder="请输入邮箱或者手机号"/>
                </div>
                <div class="item">
                    <span class="label">密码:</span>
                    <input type="password" name="password" placeholder="请输入密码"/>
                </div>
            </div>
            <div class="item-check">
                <input type="checkbox" name="rememberPass" value="1" />记住密码
                <!--<input type="checkbox" name="is_admin" value="1"  checked />管理员-->
            </div>
            <div class="clr"></div>
            <div class="control">
                <a href="{:U('Org/index')}" class="btn signin">注册</a>
                <button type="submit" class="btn login" style="border: none;">登陆</button>
            </div>
            <div class="Validform_checktip"></div>
            <!--<div class="loading"><img src="__PUBLIC__/img/loading.gif" alt=""></div>-->
        </form>
    </div>
</div>
<script>
function checkForm(){
    var e=$("[name=email]").val();
    var p=$("[name=password]").val();
//    var eRe=/(^(\w)+(\.\w+)*@(\w)+((\.\w{2,3}){1,3})$|^1(3|4|5|7|8)\d{9}$)/;
//    if(e=="" || p==""){
//        $('.Validform_checktip').html('账号和密码必须填写').addClass('Validform_wrong');
//        return false;
//    }else if(!eRe.test(e)){
//        $('.Validform_checktip').html('账号信息错误！').addClass('Validform_wrong');
//        return false;
//    }else{
//        $('.Validform_checktip').html('').removeClass('Validform_wrong');
//        return true;
//    }

    if(e == '' || p == '') {
        $('.Validform_checktip').html('账号和密码必须填写').addClass('Validform_wrong');
        return false;
    } else {
        $('.Validform_checktip').html('').removeClass('Validform_wrong');
        return true;
    }
}

$("form.login").submit(function(e){
    e.preventDefault();
    if(checkForm()){
         $(".loading").show();
        var a=false;
        $.ajax({
            type:'post',
            async:false,
            url:"{:U('Org/login')}",
            data:$('#loginForm').serialize(),
            success:function(data){
                $(".loading").hide();
                if(data.status===1){
                    $('.Validform_checktip').html('').removeClass('Validform_wrong');
                    a=true;
                    location.href=data.url;
                }else{
                   $('.Validform_checktip').html(data.info).addClass('Validform_wrong');
                   a=false;
                }
            },
            error:function(){
                $(".loading").hide();
                $('.Validform_checktip').html("无法连接服务器，请稍后重试！").addClass('Validform_wrong');
                a=false;
            }
        })
        return a;
    }else{
        return false;
    }
});

</script>
</body>
</html>